package com.wang.controller;

import com.wang.pojo.TbScheme;
import com.wang.pojo.TbSs;
import com.wang.service.TbSchemeService;
import com.wang.utills.R;
import com.wang.utills.UploadUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ServerWebExchange;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import java.io.IOException;

@RequestMapping("/case/sickness")
@RestController
public class TbsicknessController {

    @Resource
    private TbSchemeService tbSchemeService;

    /*
     * 方案
     * */
    @RequestMapping("addscheme")
    public R addschemebysid (@RequestBody TbScheme tbScheme, Integer sid){
        return this.tbSchemeService.addnewonebysid(tbScheme,sid);
    }

    /*
     * 单独添加给疾病添加方案
     * */
    @RequestMapping("getschemebytbsid/{sid}")
    public R  getschemebytbSicknesssid (@PathVariable Integer sid){
        return this.tbSchemeService.getschemebytbSicknesssid(sid);
    }


    /*
     * shanchu疾病对应方案
     * fid 方案id
     * sid 疾病id
     *
     * */
    @RequestMapping("delschemebytbSicknesssid/{fid}/{sid}")
    public R  delschemebytbSicknesssid (@PathVariable Integer fid,@PathVariable Integer sid){
        return this.tbSchemeService.delschemebytbSicknesssid(fid,sid);
    }


    /*
     * 疾病添加方案
     *
     * */
    @RequestMapping("addtbss")
    public R  addtbss (@RequestBody TbSs tbSs){
        return this.tbSchemeService.addtbss(tbSs);
    }


    @RequestMapping("ipone")
    public String getipone(MultipartFile file) throws ServletException, IOException {
        UploadUtil uploadUtil=new UploadUtil();
        String s = uploadUtil.doGet(file);
        return s;
    }

}
